package com.yundasys.lab16springbootplus.lab16springbootplus.beandefinitionregistrar;

import org.springframework.beans.factory.FactoryBean;

import java.lang.reflect.Proxy;

/**
 * @PACKAGE_NAME: com.yundasys.lab16springbootplus.lab16springbootplus.beandefinitionregistrar
 * @NAME: MyfactoryBean
 * @USER: jiangta
 * @DATE: 2022/9/22
 * @TIME: 3:33 下午
 * @PROJECT_NAME: springboot-labs
 */
public class MyfactoryBean implements FactoryBean {

    private Class clazz;

    public MyfactoryBean(Class clazz) {
        this.clazz=clazz;
    }

    @Override
    public Object getObject() throws Exception {
        Class[] clazzes=new Class[]{this.clazz};
        Object proxy= Proxy.newProxyInstance(this.getClass().getClassLoader(),clazzes,new MyInvocation());
        return proxy;
    }

    @Override
    public Class<?> getObjectType() {
        return this.clazz;
    }

    @Override
    public boolean isSingleton() {
        return false;
    }
}
